package form;

import handler.assetFormHandlers.AFTextFieldKeyListener;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JTextField;

import checker.StringChecker;

public class FormTextField extends FormInputComponent {

	public FormTextField(String label, JTextField textField, StringChecker inputChecker){
		super(label, textField, inputChecker);
	}
			
	@Override
	public void triggerUIError() {
		if(component!=null)
			component.setBackground(Color.pink);
	}
	
	@Override
	public String getInput() {
		if(component == null)
			return null;
		return ((JTextField)component).getText();
	}

	@Override
	public void clearUIError() {
		if(component!=null)
			component.setBackground(Color.white);
	}

	@Override
	public void returnUIToDefaultState() {
		if(component!=null)
			((JTextField)component).setText("");
	}

	@Override
	public void setInput(String input) {
		if(component!=null)
			((JTextField)component).setText(input);
	}
}
